package plus.logic;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import plus.util.Condition;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public interface LogicBaseFeign <T>{

    /**
     * 保存实体
     * @param entity
     * @return
     */
    @PostMapping("/save")
    boolean save(@RequestBody T entity);

    /**
     * 批量保存实体
     * @param condition 使用方法 entitys
     * @return
     */
    @PostMapping("/saveBatch")
    boolean saveBatch(@RequestBody Condition condition);

    @PostMapping("/saveOrUpdateBatch")
    boolean saveOrUpdateBatch(@RequestBody Condition condition);

    @GetMapping("/removeById")
    boolean removeById(@RequestParam("id")Serializable id);

    @PostMapping("/removeByMap")
    boolean removeByMap(@RequestBody Condition condition);

    @PostMapping("/removeByEntity")
    boolean removeByEntity(@RequestBody T entity);

    @PostMapping("/removeByIds")
    boolean removeByIds(@RequestBody Condition condition);

    @PostMapping("/updateById")
    boolean updateById(@RequestBody T entity);

    @PostMapping("/updateBatchById")
    boolean updateBatchById(@RequestBody Condition condition);

    @PostMapping("/saveOrUpdate")
    boolean saveOrUpdate(@RequestBody T entity);

    @PostMapping("/getByMap")
    T getOneByMap(@RequestBody Condition condition);

    @GetMapping("/getById")
    T getById(@RequestParam("id")Serializable id);

    @PostMapping("/listByIds")
    Collection<T> listByIds(@RequestBody Condition condition);

    @PostMapping("/listByMap")
    Collection<T> listByMap(@RequestBody Condition condition);

    @GetMapping("/count")
    int count();

    @GetMapping("/list")
    List<T> list();

    @GetMapping("/listMaps")
    List<Map<String, Object>> listMaps();

    @GetMapping("/listObjs")
    List<Object> listObjs();

    @PostMapping("/page")
    IPage<T> page(@RequestBody Condition condition);
}
